package com.eastmelon.tcp;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author Administrator
 * 实现服务器端和客户端的互访
 */
public class TcpServer2 {
	public static void main(String[] args) throws Exception {
		ServerSocket ss=new ServerSocket(10003);
		Socket s=ss.accept();
		String ip=s.getInetAddress().getHostAddress();
		System.out.println(ip+"....connected");
		InputStream in=s.getInputStream();
		byte[] buf=new byte[1024];
		int len=in.read(buf);
		System.out.println(new String(buf,0,len));
		OutputStream out=s.getOutputStream();
		out.write("哥们你也好，收到".getBytes());
		ss.close();
	}
}
